package JDBC;

import java.io.IOException;
import java.util.List;

import org.dom4j.io.SAXReader;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;

public class JdomTest {

	public static void main(String[] args) {
		
		try {
			long start = System.currentTimeMillis();
			SAXBuilder builder = new SAXBuilder();
			Document document = builder.build("sample.xml");
			Element root = document.getRootElement();
			List<Element> children = root.getChildren();
			
			for(Element child :children){
				if(!"student".equals(child.getName())){
					continue;
				}
				System.out.println("--------Studnet--------");
				System.out.println("id:" + child.getAttributeValue("id"));
				System.out.println("name:" + child.getAttributeValue("name"));
				System.out.println("gender:" + child.getAttributeValue("gender"));
				System.out.println("age:" + child.getAttributeValue("age"));
			}
		} catch (JDOMException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}

}
